<template>
  <div class="login">
    <img class="login-back" src="../assets/login/logo.png" alt="" />

    <div class="login-block">
      <div class="block-title">登录</div>
      <div class="block-text">分账系统</div>

      <div class="block-input">
        <div class="icon">
          <img class="input-icon" src="../assets/login/icon-1.png" alt="" />
        </div>
        <el-input v-model="account" placeholder="输入登录账号"></el-input>
      </div>

      <div class="block-input">
        <div class="icon">
          <img class="input-icon" src="../assets/login/icon-0.png" alt="" />
        </div>
        <el-input
          v-model="password"
          placeholder="输入密码"
          show-password
        ></el-input>
      </div>

      <div class="block-buttom" @click="registerMet">登 录</div>
    </div>
  </div>
</template>

<script>
import { postlogin, postcode } from "../api/login";

var verify = require("../utils/verify");

import Cookies from "js-cookie";

import { md5 } from "../utils/md5";
export default {
  data() {
    return {
      account: "",
      // password: "e10adc3949ba59abbe56e057f20f883e",
      password: "",
    };
  },
  methods: {
    registerMet() {
      let params = {
        loginType: "USER",
        phone: this.account,
        password: this.password == ''? '' : md5(this.password),
        // password: md5(this.password),
        code: "",
      };
      postlogin(params).then((res) => {
        // 获取登录数据
        if (res.resultStatus == true) {
          // 存储登录后个人信息
          localStorage.setItem("info", JSON.stringify(res.resultData));
          // 存储登录后的accessToken 登录凭证
          localStorage.setItem("token", res.resultData.accessToken);

          this.$router.go(0);

          if (this.checkIshow == true) {
            let obj = {
              password: this.password,
              account: this.account,
            };
            this.restaurant.push(obj);
            var jj = JSON.stringify(this.restaurant);
            // // 记住账号密码
            Cookies.set("info", jj, { expires: 30 });
          }

      
        }
      });
    },
  },
};
</script>

<style lang="less" scoped>
.login {
  width: 100vw;
  height: 100vh;
  position: relative;

  .login-back {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
  }

  .login-block {
    position: absolute;
    top: 172px;
    right: 236px;
    z-index: 1;

    width: 312px;
    height: 296px;
    background: #ffffff;
    box-shadow: 0px 2px 15px 0px rgba(71, 75, 75, 0.1);
    border-radius: 8px;
    padding: 34px 28px;
    box-sizing: border-box;
    text-align: left;

    .block-title {
      font-family: PingFangSC, PingFang SC;
      font-weight: 600;
      font-size: 18px;
      color: #292929;
    }

    .block-text {
      font-family: PingFangSC, PingFang SC;
      font-weight: 600;
      font-size: 18px;
      color: #2588fa;
      margin-top: 5px;
      margin-bottom: 23px;
    }

    .block-input {
      margin-bottom: 12px;
      position: relative;
      height: 36px;
      display: flex;
      align-items: center;

      .icon {
        width: 30px;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        left: 0;
        .input-icon {
          width: 14px;
          height: 14px;
          z-index: 10;
        }
      }

      /deep/ .el-input__inner {
        height: 36px;
        background: #ffffff;
        border-radius: 4px;
        padding-left: 30px;
      }

      ::-webkit-input-placeholder {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 12px;
        color: #949494;
      }
      ::-moz-input-placeholder {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 12px;
        color: #949494;
      }
      ::-ms-input-placeholder {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 12px;
        color: #949494;
      }
    }

    .block-buttom {
      height: 40px;
      background: #2588fa;
      border-radius: 4px;
      margin-top: 21px;
      display: flex;
      align-items: center;
      justify-content: center;

      font-family: PingFangSC, PingFang SC;
      font-weight: 600;
      font-size: 16px;
      color: #ffffff;
      cursor: pointer;
    }
  }
}
</style>